package com.eclink.iot.rfidclient.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class StringUtils {

    public static String toJSONString(Object obj) {
        ObjectMapper objectMapper = new ObjectMapper();
        String jsonString = null;
        try {
            // 将对象转换为JSON字符串
            jsonString = objectMapper.writeValueAsString(obj);
            System.out.println(jsonString);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return jsonString;
    }

}
